import { DataProvider } from "../../../../../fl/data/DataProvider";
import { ObjCreate } from "../../common/ObjCreate";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { PageSelecterOnlyPreNext } from "../../common/pageSelect/PageSelecterOnlyPreNext";
import { SCSkillRuneItemRender } from "../items/SCSkillRuneItemRender";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { ScrollPolicy } from "../../../../../flashx/textLayout/container/ScrollPolicy";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
type int = number;
//class SecondCareerSkillRune
    
    export  class SecondCareerSkillRune /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.initView();
            this._pageSelecter.addEventListener(flash.events.Event.CHANGE, this.pageChangeHandler);
            return;
        }

        public updateData(arg1: Array<any>): void
        {
            this._data = arg1;
            this._pageSelecter.currentPage = 1;
            if (this._data == null || this._data.length == 0) 
            {
                this._pageSelecter.maxPage = 1;
            }
            else 
            {
                this._pageSelecter.maxPage = Math.ceil(arg1.length / CellNum);
            }
            this.pageChangeHandler(null);
            return;
        }

        /* internal  */pageChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc4=0;
            var loc1=(this._pageSelecter.currentPage - 1);
            var loc2=new DataProvider();
            var loc3=0;
            while (loc3 < SecondCareerSkillRune.CellNum) 
            {
                loc4 = loc3 + loc1 * SecondCareerSkillRune.CellNum;
                if (this._data == null || loc4 >= this._data.length) 
                {
                    loc2.addItem(1);
                }
                else 
                {
                    loc2.addItem(this._data[loc4]);
                }
                ++loc3;
            }
            this._list.dataProvider = loc2;
            this._list.drawNow();
            return;
        }

        /* internal  */initView(): void
        {
            ObjCreate.createBg(0, 0, 490, 50, this);
            this._bgRune = new Object /* flash.display.Bitmap */();
            this._bgRune.x = 10;
            this._bgRune.y = 14;
            this.addChild(this._bgRune);
            LoaderHelp.setBitmapdata("SecondCareerSkillRune.png", this._bgRune);
            this._pageSelecter = new PageSelecterOnlyPreNext();
            this._pageSelecter.setPreNextBtnDistance(387);
            this._pageSelecter.x = 76;
            this._pageSelecter.y = 20;
            this.addChild(this._pageSelecter);
            this._list = ObjCreate.createTileList(100, 8, 360, 36, this);
            this._list.setStyle("cellRenderer", SCSkillRuneItemRender);
            this._list.direction = GBoxDirection.HORIZONTAL;
            this._list.scrollPolicy = ScrollPolicy.OFF;
            this._list.rowHeight = 36;
            this._list.columnCount = 9;
            this._list.columnWidth = 34;
            this._list.horizontalGap = 6;
            return;
        }

        public static /* const */CellNum: int=9;

        /* internal */ /* var */_pageSelecter: PageSelecterOnlyPreNext;

        /* internal */ /* var */_bgRune: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_list: GTileList;

        /* internal */ /* var */_data: Array<any>;
    }
